home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / kmediaplayer / player.h next >
Encoding:
C/C++ Source or Header  |  2005-09-10  |  4.5 KB  |  144 lines

  1. // Copyright (C) 2002 Neil Stevens <neil@qualityassistant.com>
  2. //
  3. // Permission is hereby granted, free of charge, to any person obtaining a copy
  4. // of this software and associated documentation files (the "Software"), to deal
  5. // in the Software without restriction, including without limitation the rights
  6. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7. // copies of the Software, and to permit persons to whom the Software is
  8. // furnished to do so, subject to the following conditions:
  9. // 
  10. // The above copyright notice and this permission notice shall be included in
  11. // all copies or substantial portions of the Software.
  12. // 
  13. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  14. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  15. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
  16. // THE AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
  17. // AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  18. // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  19. // 
  20. // Except as contained in this notice, the name(s) of the author(s) shall not be
  21. // used in advertising or otherwise to promote the sale, use or other dealings
  22. // in this Software without prior written authorization from the author(s).
  23.  
  24. #ifndef KMEDIAPLAYERPLAYER_H
  25. #define KMEDIAPLAYERPLAYER_H
  26.  
  27. #include <kparts/part.h>
  28. #include <kmediaplayer/playerdcopobject.h>
  29. #include <kmediaplayer/view.h>
  30.  
  31. /** KMediaPlayer contains an interface to reusable media player components.
  32. */
  33. namespace KMediaPlayer
  34. {
  35.  
  36. /** Player is the center of the KMediaPlayer interface.   It provides all of
  37.  * the necessary media player operations, and optionally provides the GUI to
  38.  * control them.
  39.  *
  40.  * There are two servicetypes for Player:  KMediaPlayer/Player and
  41.  * KMediaPlayer/Engine.  KMediaPlayer/Player provides a widget (accessable
  42.  * through view as well as XML GUI KActions.  KMediaPlayer/Engine omits
  43.  * the user interface facets, for those who wish to provide their own
  44.  * interface.
  45.  */
  46. class KDE_EXPORT Player : public KParts::ReadOnlyPart, public PlayerDCOPObject
  47. {
  48. Q_OBJECT
  49.  
  50. public:
  51.     /** This constructor is what to use when no GUI is required, as in the
  52.      * case of a KMediaPlayer/Engine.
  53.      */
  54.     Player(QObject *parent, const char *name);
  55.  
  56.     /** This constructor is what to use when a GUI is required, as in the
  57.      * case of a KMediaPlayer/Player.
  58.      */
  59.     Player(QWidget *parentWidget, const char *widgetName, QObject *parent, const char *name);
  60.  
  61.     virtual ~Player(void);
  62.  
  63.     /** A convenience function returning a pointer to the View for this
  64.      * Player, or 0 if this Player has no GUI.
  65.      */
  66.     virtual View *view(void) = 0;
  67.  
  68. public slots:
  69.     /** Pause playback of the media track.*/
  70.     virtual void pause(void) = 0;
  71.  
  72.     /** Begin playing the media track.*/
  73.     virtual void play(void) = 0;
  74.  
  75.     /** Stop playback of the media track and return to the beginning.*/
  76.     virtual void stop(void) = 0;
  77.  
  78.     /** Move the current playback position to the specified time in
  79.      * milliseconds, if the track is seekable.  Some streams may not be
  80.      * seeked.
  81.      */
  82.     virtual void seek(unsigned long msec) = 0;
  83. public:
  84.     /** Returns whether the current track honors seek requests.*/
  85.     virtual bool isSeekable(void) const = 0;
  86.  
  87.     /** Returns the current playback position in the track.*/
  88.     virtual unsigned long position(void) const = 0;
  89.  
  90.     /** Returns whether the current track has a length.  Some streams are
  91.      * endless, and do not have one. */
  92.     virtual bool hasLength(void) const = 0;
  93.  
  94.     /** Returns the length of the current track.*/
  95.     virtual unsigned long length(void) const = 0;
  96.  
  97. public slots:
  98.     /** Set whether the Player should continue playing at the beginning of
  99.      * the track when the end of the track is reached.
  100.      */
  101.     void setLooping(bool);
  102. public:
  103.     /** Return the current looping state. */
  104.     bool isLooping(void) const;
  105. signals:
  106.     /** Emitted when the looping state is changed. */
  107.     void loopingChanged(bool);
  108.  
  109. public:
  110.     /** The possible states of the Player */
  111.     enum State
  112.     {
  113.         /** No track is loaded. */
  114.         Empty,
  115.         /** Not playing. */
  116.         Stop,
  117.         /** Playing is temporarily suspended. */
  118.         Pause,
  119.         /** The media is currently being output. */
  120.         Play
  121.     };
  122.     /** Return the current state of the player. */
  123.     int state(void) const;
  124. signals:
  125.     /** Emitted when the state changes. */
  126.     void stateChanged(int);
  127.  
  128. protected slots:
  129.     /** Implementers use this to control what users see as the current
  130.      * state.*/
  131.     void setState(int);
  132.  
  133. private:
  134.     bool currentLooping;
  135.     State currentState;
  136.  
  137.     struct Data;
  138.     Data *d;
  139. };
  140.  
  141. }
  142.  
  143. #endif
  144.